<?php

namespace common\base;

/**
 * Model is the base class for data models.
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class Model extends \yii\base\Model {

    use \common\traits\ModelErrors;

    public function dumpError($message, $error = null, $code = 418) {
        if (is_object($error)) {
            /* @var $error \yii\base\Model */
            $error = $error->firstErrors;
        } else if ($error !== false) {
            $error = $this->firstErrors;
        }
        throw new ModelHttpException($message, $error, $code);
    }

}
